package com.suanfa;


import java.time.LocalDate;
import java.util.Calendar;

/**
 * @Author weijingchen
 * @Date 2025/5/27 21:31
 * @Version 1.0.0
 */
public class Test03 {
    public static void main(String[] args) {
        JDK7Num();
        JDk8Num();
    }

    private static void JDk8Num() {
        LocalDate now = LocalDate.of(2000, 3, 1);
        LocalDate localDate = now.minusDays(1);
        int dayOfMonth = localDate.getDayOfMonth();
        if (dayOfMonth==28){
            System.out.println("平年");
        }else {
            System.out.println("闰年");
        }
        System.out.println("--------jdk8可以直接判断是否是闰年---------");
        boolean leapYear = now.isLeapYear();
        if (leapYear){
            System.out.println("闰年");
        }else {
            System.out.println("平年");
        }

    }

    private static void JDK7Num() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(2000,2,1);
        calendar.add(Calendar.DAY_OF_MONTH,-1);
        int i = calendar.get(Calendar.DAY_OF_MONTH);
        if (i==28){
            System.out.println("平年");
        }else {
            System.out.println("闰年");
        }
    }
}
